﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Ex10.ExtractAllSentencesWithGivenWord
{
    class ExtractSentWithWord
    {
        public static void ExtractSentence(string text,string word)
        {
            string delimiter = @"\.|\!|\?";
            string[] sentences = Regex.Split(text, delimiter);
            foreach (var sentence in sentences) 
            {
                if (Regex.IsMatch(sentence, string.Format(@"\w*\s*{0}\s*\w*",word)))
                {
                    Console.WriteLine(sentence);
                }
            }
            
            Console.WriteLine();
        }
        static void Main(string[] args)
        {
            string text = @"Functions in PHP but test you can. Literally use the regular expression in other programming test! languages as well.";
            string word = "test";
            ExtractSentence(text, word);
        }
    }
}
